import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;

public class Test {

    public static void main(String[] args) {
        String ch1="7_This_is_a_test";
        String ch2="_hs_s_a_es";

        Oj.func(ch1,ch2);
    }
    public static void main6(String[] args) {
        Oj oj = new Oj();
        String jewels = "aA";//宝石
        String stones = "aAAbbbb";//一种集合
        System.out.println(oj.numJewelsInStones(jewels, stones));//返回宝石数量
    }
    public static void main5(String[] args) {
        Oj oj = new Oj();
        Oj.Node node1 = oj.new Node(7);
        Oj.Node node2 = oj.new Node(13);
        Oj.Node node3 = oj.new Node(11);
        Oj.Node node4 = oj.new Node(10);
        Oj.Node node5 = oj.new Node(1);
        node1.next = null;
        node1.random = null;
        node2.next = node1;
        node2.random = node1;
        node3.next = node2;
        node3.random = node5;
        node4.next = node3;
        node4.random = node2;
        node5.next = node4;
        node5.random = node1;
        Oj.Node newHead = oj.copyRandomList(node5);
        while (newHead != null) {
            System.out.println("Node val: " + newHead.val);
            if (newHead.random != null) {
                System.out.println("Random points to: " + newHead.random.val);
            } else {
                System.out.println("Random points to: null");
            }
        }

    }
    public static void main4(String[] args) {
        Oj oj = new Oj();
        int[] array = {4,1,2,1,2};
        System.out.println(oj.singleNumber(array));
    }
    public static void main3(String[] args) {
        HashBunk hashBunk = new HashBunk();
        hashBunk.put(1,12);
        hashBunk.put(2,12);
        hashBunk.put(3,12);
        hashBunk.put(5,12);
        hashBunk.put(8,12);
        hashBunk.put(11,12);
        hashBunk.put(9,12);//现在为第七个，还不会扩容
        hashBunk.put(12,12);
        hashBunk.put(13,112);//到这里的时候就超过负载因子了，就会进行扩容
        System.out.println(hashBunk.get(13));//测试通过key获取value
    }

    public static void main2(String[] args) {
        Set<String> set = new HashSet<String>();
        set.add("A");
        set.add("B");
        set.add("C");
        set.add("D");
        set.add("E");
        set.add("A");
        set.add("B");
        System.out.println(set);//测试，会自动去重
    }
    public static void main1(String[] args) {
        Map<String,Integer> map = new TreeMap<>();
        map.put("hello", 3);
        map.put("world", 5);
        map.put("OK", 4);
        System.out.println(map);//这里是直接遍历
        //使用Set<Map.Entry<K,V>> entryset映射也可完成遍历
        Set<Map.Entry<String,Integer>> entries=map.entrySet();
        for(Map.Entry<String,Integer> entry:entries){//利用for:each完成一一映射遍历
            String key=entry.getKey();
            Integer value=entry.getValue();
            System.out.println("key="+key+" "+"value="+value);
        }
    }
}
